package smartgrid;

import java.util.List;
import javax.ejb.Local;
import smartgrid.exceptions.ContractAlreadyExistsException;
import smartgrid.exceptions.FacebookAccountNotExistException;
import smartgrid.exceptions.InvalidContractNifException;
import smartgrid.exceptions.InvalidContractNumberException;

@Local
public interface Contracts {

    /**
     * 
     * @return Contract List of a Facebook Account
     */
    List<Contract> getContracts(FaceBookAccount fb);

    /**
     * 
     * @param id do contrato, ou seja, chave primaria
     * @return retorna um contrato
     */
    Contract getContract(int id);

    /**
     * 
     * @param Numero do contrato (nao o numero da chave primaria)
     * @return retorna um contrato
     */
    Contract getContractByNumber(String number);

    /**
     * Inserts one new Contract
     * 
     * @param contractNumber Number of the Contract
     * @param clientName Client's name
     * @param clientNif Client's NIF number
     * @param supplierID Supplier's DB id
     * @param tariffID Tariff's DB id
     * @return if success: true
     */
    Boolean insertContract(String contractNumber, String clientName, String clientNif, Integer supplierID, Integer tariffID, String morada);

    /**
     * Updates the contract's tariif.
     * 
     * @param contractID The primary key of the contract
     * @param tariffID The primary key of the tariff
     * @return if success: true
     */
    Boolean updateContract(Integer contractID, Integer tariffID);

    /**
     * adds one Contract of one supplier to one facebookAccount
     * 
     * @param facebookAccountUID Facebook UID
     * @param supplierID Supplier primary key
     * @param contractNumber Number of Contract 
     * @param contractNif NIF of registered contract
     * @return if success: true
     */
    void addContractToFacebookAccount(String facebookAccountUID, Integer supplierID, String contractNumber, String contractNif) throws InvalidContractNifException, InvalidContractNumberException, ContractAlreadyExistsException, FacebookAccountNotExistException;

    /**
     * Removes one Contract from one Facebook Account
     * @param facebookUID Facebook account primary key
     * @param contractNumber Contract primary key
     * @return If Success True
     */
    Boolean removeContractFromFacebookAccountByORMID(String facebookID, String contractID);

    /**
     * Removes one Contract from one Facebook Account
     * @param facebookUID Facebook UID
     * @param contractNumber Number of the Contract
     * @return If Success True
     */
    Boolean removeContractFromFacebookAccount(String facebookUID, String contractNumber);

    public List<Contract> getContracts();
}